package com.chinamobile.ln.ictenterprises.utils;

import java.io.IOException;
import java.io.InputStream;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;

public class BitmapUtil
{

    public static BitmapDrawable getBitmapDrawable(Context context, int resId)
    {
        BitmapFactory.Options opt = new BitmapFactory.Options();
        opt.inPreferredConfig = Bitmap.Config.RGB_565;
        opt.inPurgeable = true;
        opt.inInputShareable = true;

        InputStream is = context.getResources().openRawResource(resId);
        Bitmap bitmap = BitmapFactory.decodeStream(is, null, opt);

        try
        {
            is.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

        return new BitmapDrawable(context.getResources(), bitmap);

    }
}
